# -*- coding: utf-8 -*-
import requests
import json
from util.wechatpy import WechatToken

class WeChatCustom(WechatToken):

    def init(self):

        self.url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s" % self.access_token

    def send(self, openid="", content=u""):

        data = {"touser": "%s" % openid,
                "msgtype": "text",
                "text": {"content": content}
               }

        print self.url
        print data

        return json.loads(requests.post(self.url, json.dumps(data, ensure_ascii=False).encode("utf-8")).content.decode("utf-8"))